<template>
  <div class="version">
    <span class="pattern left">
      <img src="https://ali-static.fir.im/download_pattern_left.png" />
    </span>
    <span class="pattern right">
      <img src="https://ali-static.fir.im/download_pattern_right.png" />
    </span>
    <div class="release-main">
      <div>
      <span class="icon-container-icon">
        <img :src="iconImg"/>
      </span>
      <div class="release-name">
        <img  :src="appType==='Android'?androidImg:appleImg" />
        <span>Beijing</span>
      </div>
      <div v-if="status">
        <a :href="appUrl"  class="login-button">下载安装</a>
      </div>
      <span v-else  class="errorText">{{errorText}}</span>
      </div>
    </div>
    <div v-if="weiXin" class="back-div">
      <div style="width: 90%; text-align: right; margin: 5px auto 0px auto;">
        <img src="@/assets/img/fenxiang.png" style="width: 25%;"/>
        </div>		
      <div class="back-font">
      1.点击"右上角"在"浏览器"<br />中打开<br /><br />		
      2.用浏览器扫描二维码</div>
	</div>
  </div>
</template>
<script>
// 获取用户信息
import { dictionary } from '@/utils/dictMixin';
import { exportExcelFile } from '@/utils/index';
import { authority } from '@/utils/authMixin';
import Cookies from 'js-cookie';
import androidImg from '@/assets/img/android.jpg';
import appleImg from '@/assets/img/apple.jpg';
import iconImg from '@/assets/img/app2.png';
import { queryDataByAppType } from '@/api/login/index';
export default {
  name: 'quotedprice',
  data() {
    return {
      androidImg: androidImg,
      appleImg: appleImg,
      iconImg:iconImg,
      appUrl: '',
      appType: this.$route.query.appType,
      versionNo:'未知',
      createdDate:'未知',
      status:true,
      weiXin:false,
      errorText:''
      }
  },
  async mounted() {
    const u = navigator.userAgent;
    if (u.toLowerCase().indexOf('micromessenger') !== -1) {  //微信浏览器
      this.weiXin=true
      return 
    }
    const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
    if (isiOS) {
      this.appType = 'IOS';
    } else {
      this.appType = 'Android';
    }
   if(this.$route.query.appType && this.appType!==this.$route.query.appType){
       this.errorText='数据类型和手机类型不符'
       this.status=false
       return
    }
    if(this.$route.query.url){
        const url=this.$route.query.url
        this.appUrl=this.$route.query.appType==='IOS'?url[0]+'&url='+url[1]:url
        this.status=true
        }else{
        this.appSource()
    }
  },
  methods: {
    async appSource() {
      let params = {
        appDownLoadType:this.appType, //必传
        appId: 'beijing' //必传
      }
      await queryDataByAppType(params).then(res => {
        if (res.resultCode == 200  && res.data) {
          this.status=true
          this.versionNo=res.data.versionNo
          this.createdDate=res.data.createdDate
          this.appUrl = res.data.url;
          this.appIsShow = true;
        } else {
          this.status=false
          this.errorText='获取地址失败'
        }
      });
      }
  }
};
</script>

<style lang="less" scoped>
.version {
  width: 100%; height: 100%;
}
.pattern {
  position: absolute;
  top: 0;
  z-index: 1;
  max-width: 312px;
  width: 21.66%;
  transition: all 0.5s;
}
.pattern img {
  width: 100%;
}
.left {
  left: 0;
}
.right {
  right: 0;
}
.icon-container-icon {
  top: 0;
  left: 0;
  padding: 10px;
  width: 140px;
  height: 140px;
  border-radius: 17.54%;
  background-color: #fff;
}
.icon-container-icon img {
  max-width: 100%;
  width: 120px;
  height: 120px;
  border-radius: 17.54%;
}
.release-main {
  text-align: center;
  padding-top: 120px;
  margin: 0 auto;
  max-width: 90%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.release-info {
  position: relative;
  margin-top: 15px;
  margin-bottom: 30px;
  padding-top: 30px;
  line-height: 26px;
  color: #a9b1b3;
  font-size: 14px;
}
.release-info:before {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  margin-left: -30%;
  width: 60%;
  border-top: 1px solid #dae2e3;
  content: ' ';
}
.release-name {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 120px;
  padding-top: 30px;
  color: #333;
  font-size: 28px;
}
.release-name img {
  width: 26px;
  height: 26px;
  padding-right: 6px;
}
.login-button {
  padding: 15px 0px;
  min-width: 120px;
  width: 40%; display:inline-block;
  border: 1px solid @primaryColor;
  border-radius: 40px;
  font-size: 14px;
  background: @primaryColor;
  color: #fff; cursor: pointer;
}
.errorText{ background: rgb(250, 236, 216); border:#E6A23C solid 1px; padding:3px 8px;}
.back-div{position:fixed; top:0px; left:0px; background:rgba(0,0,0,0.7); width:100%; height: 100%;  color: #fff; z-index: 999;}
.back-font{font-size:1.1em; margin-top: -20px; color: #fff; padding-left: 8%; text-align: left; line-height:30px;}
</style>
